package com.anwen.mongoa.controller;

import com.anwen.mongoa.entity.base.R;
import com.anwen.mongoa.entity.dto.StudentDTO;
import com.anwen.mongoa.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jungle
 * @create 2024-05-22 16:42
 */
@Api(tags = "学生接口测试")
@RequestMapping("/student")
@RestController
@Slf4j
public class StudentController {
    @Resource
    private StudentService studentService;
    @ApiOperation("新增学生")
    @PostMapping("/add")
    public R add(@RequestBody StudentDTO dto) {
       Boolean b= studentService.save(dto);
        return R.isSuccess(b, b);
    }

    @ApiOperation("删除学生")
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Long> ids) {
        Boolean b= studentService.delete(ids);
        return R.isSuccess(b, b);
    }


    @ApiOperation("更新学生")
    @PutMapping("/update")
    public R update(@RequestBody StudentDTO dto) {
        Boolean b= studentService.update(dto);
        return R.isSuccess(b, b);
    }


    @ApiOperation("学生列表")
    @GetMapping("/list")
    public R list(StudentDTO dto) {
        Boolean b = studentService.page(dto);
        return R.isSuccess(b, b);
    }


}
